<?php

namespace App\Services;

use App\Models\Category;
use App\Models\Comment;
use App\Models\Invitation;
use App\Models\Tag;
use App\Models\User;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;

class Event extends Model
{

    protected $guarded = [];
    protected $casts = [
        'start_at' => 'datetime',
        'end_at' => 'datetime',
    ];
    public function tags(): BelongsToMany
    {
        return $this->belongsToMany(Tag::class,'event_tag','event_id','tag_id');
    }

    public function category()
    {
        return $this->belongsTo(Category::class);
    }

    public function participants()
    {
        return $this->belongsToMany(User::class,'event_attendee');
    }

    public function comments()
    {
        return $this->hasMany(Comment::class);
    }

    public function creator()
    {
        return $this->belongsTo(User::class,'creator_id');
    }

    public function invitations()
    {
        return $this->hasMany(Invitation::class);
    }


}
